<style lang="scss" scoped>
    @import '~@/assets/common/mixin.scss'; // @include flexbox()
    @import '~@/assets/common/theme.scss';
    .homeBox {
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0px;
        background-color: #ffffff;
    }

    .user-container {
        @include wh(10rem, 100%);



        .clear {
            width: 16px;
            height: 16px;
            margin: 0;
            position: absolute;
            right: 10px;
            @include bg('~@/assets/images/close.png');
        }

        .my-header {
            padding: $padding;
            background: #fff;
            @include flexbox(space-between, center, row, nowrap);
            margin-bottom: 30px;

            .back {
                display: block;
                width: .65rem;
                height: .65rem;
                background: url('~@/assets/images/close.png') no-repeat;
                background-size: 100%;
            }

            strong {
                font-size: 18px;
                font-weight: normal;
                color: #333;
            }

            .myMsg {
                display: block;
                height: .65rem;
                width: .65rem;
                opacity: 0;
            }
        }

        /* 注册 */
        .registered-container {
            height: 100%;
            background: #f8f8f8;

            .my-header .back {
                background: url('~@/assets/images/arrow-left.png') no-repeat;
                background-size: 100%;
            }

            .cell-box {
                padding: 30px 15px;

                > p {
                    padding: 15px 0;
                    font-size: $title;
                    color: #333;
                    text-align: left;
                    padding: 16px;
                }

                .phone-cell {
                    position: relative;
                    background: #fff;
                    padding: $padding;
                    @include placeholderColor($gray);
                    width: 100%;

                    input {
                        width: 100%;
                        border: none;
                        outline: none;
                        box-shadow: none;
                        text-shadow: none;
                        text-align: left;
                        font-size: $title;
                        color: #333;
                    }
                }

                .registered-code-cell {
                    @include flexbox(space-between,
                        center,
                        row,
                        nowrap);
                    padding: 0 16px;

                    .code-cell {
                        width: 50%;
                        background: #fff;
                        position: relative;
                        padding: $padding;
                        @include placeholderColor($gray);

                        input {
                            width: 100%;
                            border: none;
                            outline: none;
                            box-shadow: none;
                            text-shadow: none;
                            text-align: left;
                            font-size: $title;
                            color: #333;
                        }
                    }

                    .registered-getCode {
                        width: 50%;
                        background: $red;
                        color: #fff;
                        font-size: 16px;
                        text-align: center;
                        margin-left: 10px;
                        border-radius: 2px;
                        padding: 10px 0;
                    }
                }
            }
        }

        /* 忘记密码 */
        .forget-container {
            height: 100%;
            background: #f8f8f8;

            .my-header .back {
                background: url('~@/assets/images/arrow-left.png') no-repeat;
                background-size: 100%;
            }

            .forget-content {
                font-size: $title;
                text-align: left;

                .forget-validate {
                    margin-top: $margin;
                    padding: 16px;

                    .validate-username {
                        @include flexbox(space-between,
                            center,
                            row,
                            nowrap);

                        span {
                            font-size: $title;
                            color: #333;
                            margin-right: 10px;
                        }

                        background: #fff;
                        position: relative;
                        padding: $padding;
                        @include placeholderColor($gray);

                        input {
                            width: 80%;
                            border: none;
                            outline: none;
                            box-shadow: none;
                            text-shadow: none;
                            text-align: left;
                            font-size: $title;
                            color: #333;
                        }
                    }
                }

                .forget-code-tip {
                    color: $red;
                    padding: 16px;
                }

                .forget-username-tip {
                    color: #333;
                    padding: 16px;
                }
            }

            .cell-box {
                padding: 15px;

                > p {
                    padding: 15px 0;
                    font-size: $title;
                    color: #333;
                    text-align: left;
                    padding: 16px;
                }

                .phone-cell {
                    position: relative;
                    background: #fff;
                    padding: $padding;
                    @include placeholderColor($gray);
                    width: 100%;

                    input {
                        width: 100%;
                        border: none;
                        outline: none;
                        box-shadow: none;
                        text-shadow: none;
                        text-align: left;
                        font-size: $title;
                        color: #333;
                    }
                }

                .registered-code-cell {
                    @include flexbox(space-between,
                        center,
                        row,
                        nowrap);
                    padding: 0 16px;

                    .code-cell {
                        width: 50%;
                        background: #fff;
                        position: relative;
                        padding: $padding;
                        @include placeholderColor($gray);

                        input {
                            width: 100%;
                            border: none;
                            outline: none;
                            box-shadow: none;
                            text-shadow: none;
                            text-align: left;
                            font-size: $title;
                            color: #333;
                        }
                    }

                    .registered-getCode {
                        width: 50%;
                        background: $red;
                        color: #fff;
                        font-size: 16px;
                        text-align: center;
                        margin-left: 10px;
                        border-radius: 2px;
                        padding: 10px 0;
                    }
                }
            }
        }
    }

    .from-user {
        padding: $padding;
        background: #fff;

        .cell-list {
            .cell-item {
                @include flexbox(flex-start,
                    center,
                    row,
                    nowrap);
                border-bottom: 1px solid #eee;
                padding: $padding $padding $padding 0;
                margin: $margin 0;
                position: relative;

                .left {
                    span {
                        font-size: $title;
                        color: #333;
                    }
                }

                .right {
                    width: 70%;
                    margin-left: 20px;
                    @include placeholderColor($gray);

                    input {
                        width: 100%;
                        border: none;
                        outline: none;
                        box-shadow: none;
                        text-shadow: none;
                        text-align: left;
                        font-size: $title;
                        color: #333;
                    }

                    .arrow-right {
                        display: block;
                        width: 16px;
                        height: 20px;
                        background: url('~@/assets/images/arrow-right.png') no-repeat;
                        background-size: 100%;
                    }
                }
            }
        }

        .other-link {
            @include flexbox(space-between,
                center,
                row,
                nowrap);
            font-size: 15px;
            color: $gray;
            margin-top: $margin;
        }
    }

</style>
<style scoped>
    .homeBox {
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0px;
        background-color: #ffffff;
    }
</style>
<style scoped>
    @import "https://unpkg.com/mint-ui/lib/style.css";
</style>


<template>
    <div class="user-container homeBox">

        <!-- 登陆 -->
        <mt-popup v-model="visiblePopup.login" :closeOnClickModal="true" :modal="false" position="bottom"
                  class="modal-popup">
            <div class="my-header">
                <i class="back" @click="closeOpen"></i>
                <strong>登录</strong>
                <i class="myMsg"></i>
            </div>
            <div class="from-user">
                <div class="cell-list">
                    <div class="cell-item">
                        <div class="left">
                            <span>账号</span>
                        </div>
                        <div class="right">
                            <input v-focus v-validate.initial="'required'" type="text" name="username"
                                   v-model="loginForm.username" placeholder="请输入用户名"  style="">
                        </div>
                        <i class="clear" style="" v-show="loginForm.username.length>0"
                           @click="loginForm.username=''"></i>
                    </div>
                    <div class="cell-item">
                        <div class="left">
                            <span>密码</span>
                        </div>
                        <div class="right">
                            <input v-validate.initial="'required'" name="password" @keyup.enter="Login"
                                   :type="loginForm.passwordFormType" v-model="loginForm.password" placeholder="请输入密码">
                        </div>
                        <i class="clear" style="right: 40px;" v-show="loginForm.password.length>0" @click="loginForm.password=''"
                           ></i>
                        <i :class="['eye-icon', loginForm.passwordFormType=='password'?'eye-close-icon':'']"
                           style="position: absolute;right: 10px;"
                           @click="loginForm.passwordFormType=loginForm.passwordFormType=='password'?'text':'password'"></i>
                    </div>
                </div>
                <div :class="['cell-btn',errors.has('username')||errors.has('password')?'disabled-btn':'']"
                     @click="()=>{errors.has('username')||errors.has('password')?false:Login()}">登录
                </div>
                <div class="other-link">
                    <span @click="()=>visiblePopup.registered=true">注册</span>
                    <!--<span @click="()=>visiblePopup.forget=true">忘记密码</span>-->
                </div>
            </div>
        </mt-popup>
        <!-- 登录 -->

        <!-- 注册 -->
        <mt-popup v-model="visiblePopup.registered" :closeOnClickModal="true" :modal="false" position="right"
                  class="modal-popup">
            <div class="registered-container" style="background-color: white;">
                <div class="my-header">
                    <i class="back" @click="()=>visiblePopup.registered=false"></i>
                    <strong>注册</strong>
                    <i class="myMsg"></i>
                </div>
                <div class="cell-box">
                    <div class="phone-cell" style="border:0.2px solid #e5e5e5">
                        <input v-focus v-validate.initial="'phone|required'" name="registered-phone" type="number"
                               v-model="registeredForm.tel" placeholder="请输入手机号"  style="border: black;">
                        <i class="clear"  v-show="registeredForm.tel.length>0"
                           @click="registeredForm.tel=''" style="right: 10px;top:12px;"></i>
                    </div>
                    <br>
                    <div class="phone-cell" style="border:0.2px solid #e5e5e5">
                        <input v-focus v-validate.initial="'identity|required'" name="registered-identity" type="text"
                               v-model="registeredForm.identity" placeholder="请输入身份证号"  style="border: black;">
                        <i class="clear"  v-show="registeredForm.identity.length>0"
                           @click="registeredForm.tel=''" style="right: 10px;top:12px;"></i>
                    </div>

                    <span>{{ errors.first("registered-phone")}}</span><br>
                    <span>{{ errors.first("registered-identity")}}</span>
                    <div :class="['cell-btn',errors.has('registered-phone')|errors.has('registered-identity')?'disabled-btn':'']" @click="registeredNext">
                        下一步
                    </div>
                </div>
            </div>
            <mt-popup v-model="visiblePopup.registeredCode" :closeOnClickModal="true" :modal="false" position="right"
                      class="modal-popup">
                <div class="registered-container">
                    <div class="my-header">
                        <i class="back" @click="()=>visiblePopup.registeredCode=false"></i>
                        <strong>快速注册</strong>
                        <i class="myMsg"></i>
                    </div>
                    <div class="cell-box">
                        <p>请输入{{registeredForm.phone}}收到的验证码</p>
                        <div class="registered-code-cell">
                            <div class="code-cell">
                                <input v-focus v-validate.initial="'required'" name="registeredCode" type="tel"
                                       v-model="registeredForm.code" placeholder="请输入验证码">
                                <i class="clear" v-show="registeredForm.code.length>0" @click="registeredForm.code=''"
                                   style="right: 10px;top:12px;"></i>
                            </div>
                            <div :class="['registered-getCode',registeredForm.resetSendPhoneMessage?'disabled-btn':'']"
                                 @click="registeredSendPhoneMessage"
                                 :disabled="registeredForm.resetSendPhoneMessage">{{registeredForm.resetSendPhoneMessage
                                ? `(${registeredForm.resetSendPhoneMessage})` : '获取验证码'}}
                            </div>
                        </div>
                        <div :class="['cell-btn',errors.has('registeredCode')?'disabled-btn':'']"
                             @click="vertifyNext();">下一步
                        </div>
                    </div>
                </div>
            </mt-popup>
        </mt-popup>




            <mt-popup v-model="visiblePopup.registeredFormId" :closeOnClickModal="true" :modal="false" position="right"
                      class="modal-popup">
                <div class="registered-container" style="background-color: white;">
                    <div class="my-header">
                        <i class="back" @click="()=>visiblePopup.registeredFormId=false"></i>
                        <strong>填写注册信息</strong>
                        <i class="myMsg"></i>
                    </div>
                    <div class="from-user">
                        <div class="cell-list">
                            <div class="cell-item">
                                <div class="left">
                                    <span>用户昵称</span>
                                </div>
                                <div class="right">
                                    <input v-focus v-validate.initial="'required'" type="text"
                                           name="registeredMemberName" v-model="registeredForm.username"
                                           placeholder="请输入用户名">
                                </div>
                                <i class="clear" style="" v-show="registeredForm.username.length>0"
                                   @click="registeredForm.username=''"></i>
                            </div>
                            <div class="cell-item">
                                <div class="left">
                                    <span>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</span>
                                </div>
                                <div class="right">
                                    <input v-validate.initial="'required'" name="registeredPassword"
                                           :type="registeredForm.passwordFormType" v-model="registeredForm.password"
                                           placeholder="请输入密码">
                                </div>
                                <i class="clear"  v-show="registeredForm.password.length>0"
                                   @click="registeredForm.password=''" style="right: 40px;"></i>
                                <i :class="['eye-icon', registeredForm.passwordFormType=='password'?'eye-close-icon':'']"
                                   style="position: absolute;right: 10px;"
                                   @click="registeredForm.passwordFormType=registeredForm.passwordFormType=='password'?'text':'password'"></i>
                            </div>
                            <div class="cell-item">
                                <div class="left">
                                    <span>确认密码</span>
                                </div>
                                <div class="right">
                                    <input v-validate.initial="'required'" name="registeredConfirmPassword"
                                           :type="registeredForm.passwordConfirmFormType"
                                           v-model="registeredForm.confirmpassword"
                                           placeholder="请重新输入确认密码">
                                </div>
                                <i class="clear" v-show="registeredForm.confirmpassword.length>0"
                                   @click="registeredForm.confirmpassword=''" style="right: 40px;"></i>
                                <i :class="['eye-icon', registeredForm.passwordConfirmFormType=='password'?'eye-close-icon':'']"
                                   style="position: absolute;right: 10px;"
                                   @click="registeredForm.passwordConfirmFormType=registeredForm.passwordConfirmFormType=='password'?'text':'password'"></i>
                            </div>
                        </div>
                    </div>
                    <span v-show="registeredForm.password!=registeredForm.confirmpassword">密码不一致</span>
                    <div class="cell-box">
                        <div
                            :class="['cell-btn',registeredForm.password!=registeredForm.confirmpassword|| errors.has('registeredMemberName') || errors.has('registeredPassword') || errors.has('registeredConfirmPassword') ?'disabled-btn':'']"
                            @click="visiblePopup.gender=true;">下一步
                        </div>
                    </div>
                </div>
            </mt-popup>
        </mt-popup>

        <mt-popup v-model="visiblePopup.gender" closeOnClickModal="true" :modal="false" position="right"
                  class="modal-popup">
            <div class="registered-container" >
                <div class="my-header">
                    <i class="back" @click="()=>visiblePopup.gender=false"></i>
                    <strong>选择性别和生日</strong>
                    <i class="myMsg"></i>
                </div>

                    <mt-radio
                        title="选择性别"
                        v-model="registeredForm.gender"
                        :options="options">
                    </mt-radio>
                <mt-datetime-picker
                    ref="picker"
                    type="date"
                    @confirm="handleConfirm"
                    v-model="registeredForm.birthday"


                    :startDate="startDate"


                >
                </mt-datetime-picker>
                <div class="birthday" @click="openPicker">选择生日</div>
                <div class="cell-btn" @click="registered">注册</div>
            </div>

        </mt-popup>

        <!-- 注册 -->

        <!-- 忘记密码 -->
        <mt-popup v-model="visiblePopup.forget" :closeOnClickModal="true" :modal="false" position="right"
                  class="modal-popup">
            <div class="forget-container">
                <div class="my-header">
                    <i class="back" @click="()=>visiblePopup.forget=false"></i>
                    <strong>忘记密码</strong>
                    <i class="myMsg"></i>
                </div>
                <div class="forget-content">
                    <div class="forget-validate">
                        <div class="validate-username">
                            <span>账号</span>
                            <input v-focus v-model="forgetForm.phone" v-validate.initial="'required'"
                                   name="forgetusername" type="text" placeholder="用户名/手机号">
                            <i class="clear" v-show="forgetForm.phone.length>0" @click="forgetForm.phone=''"
                               style="right: 10px;top:12px;"></i>
                        </div>
                        <div :class="['cell-btn',errors.has('forgetusername')?'disabled-btn':'']" @click="()=>{
              if(!errors.has('forgetusername')){
                setPasswordNext()
              }
            }">下一步
                        </div>
                    </div>
                </div>
            </div>
            <mt-popup v-model="visiblePopup.forgetCode" :closeOnClickModal="true" :modal="false" position="right"
                      class="modal-popup">
                <div class="forget-container">
                    <div class="my-header">
                        <i class="back" @click="()=>visiblePopup.forgetCode=false"></i>
                        <strong>忘记密码</strong>
                        <i class="myMsg"></i>
                    </div>
                    <div class="forget-content">
                        <p class="forget-code-tip">请输入{{forgetForm.phone}}收到的验证码</p>
                        <p class="forget-username-tip">用户名: {{forgetForm.userName}}****</p>
                        <div class="cell-box">
                            <div class="registered-code-cell">
                                <div class="code-cell">
                                    <input v-focus v-validate.initial="'required'" name="forgetCode" type="tel"
                                           v-model="forgetForm.code" placeholder="请输入验证码">
                                    <i class="clear" v-show="forgetForm.code.length>0" @click="forgetForm.code=''"
                                       style="right: 10px;top:12px;"></i>
                                </div>
                                <div :class="['registered-getCode',forgetForm.resetSendPhoneMessage?'disabled-btn':'']"
                                     @click="forgetSendPhoneMessage" :disabled="forgetForm.resetSendPhoneMessage">
                                    {{forgetForm.resetSendPhoneMessage ? `(${forgetForm.resetSendPhoneMessage})` :
                                    '获取验证码'}}
                                </div>
                            </div>
                            <div :class="['cell-btn',errors.has('forgetCode')?'disabled-btn':'']"
                                 @click="()=>{errors.has('forgetCode')?false: visiblePopup.forgetResetPassword=true }">
                                下一步
                            </div>
                        </div>
                    </div>
                </div>
            </mt-popup>
            <mt-popup v-model="visiblePopup.forgetResetPassword" :closeOnClickModal="true" :modal="false"
                      position="bottom" class="modal-popup">
                <div class="my-header">
                    <i class="back" @click="()=>visiblePopup.forgetResetPassword=false"></i>
                    <strong>设置密码</strong>
                    <i class="myMsg"></i>
                </div>
                <div class="from-user">
                    <div class="cell-list">
                        <div class="cell-item">
                            <div class="left">
                                <span>输入新密码</span>
                            </div>
                            <div class="right">
                                <input v-validate.initial="'required'" name="forgetFormPassword"
                                       :type="forgetForm.passwordFormType" v-model="forgetForm.password"
                                       placeholder="请输入新的密码，位数6-12位">
                            </div>
                            <i class="clear"  v-show="forgetForm.password.length>0"
                               @click="forgetForm.password=''" style="right: 40px;"></i>
                            <i :class="['eye-icon', forgetForm.passwordFormType=='password'?'eye-close-icon':'']"
                               style="position: absolute;right: 10px;"
                               @click="forgetForm.passwordFormType=forgetForm.passwordFormType=='password'?'text':'password'"></i>
                        </div>
                        <div class="cell-item">
                            <div class="left">
                                <span>确认新密码</span>
                            </div>
                            <div class="right">
                                <input v-validate.initial="'required'" name="forgetFormConfirmPassword"
                                       :type="forgetForm.confirmPasswordFormType" v-model="forgetForm.confirmPassword"
                                       placeholder="请输入确认密码">
                            </div>
                            <i class="clear"  style="right: 40px;" v-show="forgetForm.confirmPassword.length>0"
                               @click="forgetForm.confirmPassword=''"></i>
                            <i :class="['eye-icon', forgetForm.confirmPasswordFormType=='password'?'eye-close-icon':'']"
                               style="position: absolute;right: 10px;"
                               @click="forgetForm.confirmPasswordFormType=forgetForm.confirmPasswordFormType=='password'?'text':'password'"></i>
                        </div>
                    </div>
                    <div
                        :class="['cell-btn',(!errors.has('forgetFormPassword')&&!errors.has('forgetFormConfirmPassword'))&&forgetForm.password === forgetForm.confirmPassword?'':'disabled-btn']"
                        @click="setPassword">确认
                    </div>
                </div>
            </mt-popup>
        </mt-popup>
         忘记密码
    </div>
</template>
<script>

import {
        Field,
        Button,
        Toast,
        Popup,
    } from 'mint-ui';

import formateDate from '../../filiter/date'
import {sendSms,vertifyCode} from '@/api/register'

export default {
    data () {
        return {
            visiblePopup: {
                login: true,
                registered: false,
                registeredCode: false,
                forget: false,
                forgetCode: false,
                registeredFormId: false,
                forgetResetPassword: false,
                gender:false,
                car:false
            },
            startDate:new Date(new Date().getFullYear() - 100, 0, 1),
            loginForm: {
                username: '',
                password: '',
                passwordFormType: 'password'
            },
            options:[
                {
                    label:'男',
                    value:"0"
                },
                {
                    label:'女',
                    value:"1"
                }
            ],
            registeredForm: {
                tel: '',
                username: '',
                password: '',
                confirmpassword: '',
                passwordFormType: 'password',
                passwordConfirmFormType: 'password',
                resetSendPhoneMessage: null,
                code: '',
                gender:'',
                birthday:'',
                identity:'35135619990423523x',
            },
            forgetForm: {
                resetSendPhoneMessage: null,
                userName: null,
                password: '',
                passwordFormType: 'password',
                confirmPasswordFormType: 'password',
                confirmPassword: '',
                phone: '',
                code: ''
            }
        }
    },
    components: {},
    methods: {
        openPicker() {

            this.$refs.picker.open();

        },
        handleConfirm(value) {
            this.registeredForm.birthday = this.formatDate(value);
        },
        formatDate(date) {
            return formateDate(date,"yyyy-MM-dd")
        },
        closeOpen () {
            this.visiblePopup.login = false
            setTimeout(() => {
                this.$router.go(-1)
            }, 200)
        },
        async vertifyNext(){

            vertifyCode(this.registeredForm.tel,this.registeredForm.code).then(res=>{
                let data =res;
                console.log(res)
                console.log(data)
                if(data.smsCode==500){
                    alert(data.reason)
                }else{
                    this.visiblePopup.registeredFormId = true
                }
            }).catch(error=>{
                    alert(error)
            })

        },
        async setPassword () { // 设置密码
            let {
                Code,
                Message
            } = await this.$store.dispatch('SetPassword', {
                phone: this.forgetForm.phone,
                challengecode: this.forgetForm.code,
                newpassword: this.forgetForm.confirmPassword
            })
            Toast({
                message: Code === 0 ? '修改成功' : Message,
                position: 'bottom'
            })
            this.visiblePopup.forget = false
            this.visiblePopup.forgetCode = false
            this.visiblePopup.forgetResetPassword = false
        },

         registered :function() { // 注册账号


             //var registerData = JSON.stringify(this.registeredForm).replace(/\"/g, "\\'");
             console.log(this.registeredForm)
            this.$store.dispatch("Register",this.registeredForm).then(res=>{
                console.log(res);
                alert("注册成功");
                this.visiblePopup.registered = false
                this.visiblePopup.registeredCode = false
                this.visiblePopup.registeredFormId = false
                this.visiblePopup.gender = false

               // this.$router.push({path: '/'})
            }).catch(error=>{
                alert(error);
            })

            // let formData = {
            //     username: this.registeredForm.username,
            //     password: this.registeredForm.confirmpassword,
            //     phone: this.registeredForm.phone,
            //     challengecode: this.registeredForm.code
            // }
            // this.$store.dispatch('Registered', formData).then(response => {
            //     Toast({
            //         message: '注册成功',
            //         position: 'bottom'
            //     })
            //     this.visiblePopup.registered = false
            //     this.visiblePopup.registeredCode = false
            //     this.visiblePopup.registeredFormId = false
            // }, err => {
            //     return Toast({
            //         message: err.message,
            //         position: 'bottom'
            //     })
            // })
        },
        async registeredNext () { // 注册账号发送短信
            this.visiblePopup.registeredCode =true;
            //this.visiblePopup.registeredFormId =true
            // this.$store.dispatch('GetUserInfo', {
            //     MemberToken: this.registeredForm.phone
            // }).then(response => {
            //     if (response.Code === 0) {
            //         return Toast({
            //             message: '该手机已被注册',
            //             position: 'bottom'
            //         })
            //     }
            // }, err => {
            //     this.visiblePopup.registeredCode = true
            // })
        },
        async setPasswordNext () { // 忘记密码
            let {
                Code,
                Message,
                Data
            } = await this.$store.dispatch('GetUserInfo', {
                MemberToken: this.forgetForm.phone
            })
            if (Code !== 0) {
                return Toast({
                    message: Message,
                    position: 'bottom'
                })
            }
            this.forgetForm.userName = Data.username
            this.visiblePopup.forgetCode = true
        },
        async registeredSendPhoneMessage () { // 获取验证码
            // await this.$store.dispatch('SendPhoneMessage', {
            //     phone: this.registeredForm.phone
            // })

            //registeredForm.code

            sendSms(this.registeredForm.tel).then(res=>{

            }).catch(error=>{
                alert(error)
            });
            this.registeredForm.resetSendPhoneMessage = 120
            let times = setInterval(() => {
                if (this.registeredForm.resetSendPhoneMessage <= 0) {
                    this.registeredForm.resetSendPhoneMessage = null
                    clearInterval(times)
                } else {
                    this.registeredForm.resetSendPhoneMessage--
                }
            }, 1000)
        },
        async forgetSendPhoneMessage () { // 获取验证码
            await this.$store.dispatch('SendPhoneMessage', {
                phone: this.forgetForm.phone
            })
            this.forgetForm.resetSendPhoneMessage = 120
            let times = setInterval(() => {
                if (this.forgetForm.resetSendPhoneMessage <= 0) {
                    this.forgetForm.resetSendPhoneMessage = null
                    clearInterval(times)
                } else {
                    this.forgetForm.resetSendPhoneMessage--
                }
            }, 1000)
        },
        async Login () { // 登录
            // let Data = await this.$store.dispatch('Login', {
            //     username: this.loginForm.username,
            //     password: this.loginForm.password
            // })
            // if (Data.Code !== 0) {
            //     return Toast({
            //         message: Data.Message,
            //         position: 'bottom'
            //     })
            // }
            // this.$router.go(-1)
            this.$store.dispatch('Login', this.loginForm).then(() => {
                this.loading = false;
                this.$router.push({path: '/'})
            }).catch(error => {
                console.log(error)
            })
        }
    },
    mounted: function () {
    }
}

</script>
